package com.lsw.pullableview;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

public class PullableWebView extends WebView implements Pullable {
    private boolean isCanPullup = false;
    private boolean isCanPuldown = false;

    public PullableWebView(Context context) {
        super(context);
    }

    public PullableWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PullableWebView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean canPullDown() {
        if (isCanPuldown) {
            if (getScrollY() == 0)
                return true;
            else
                return false;
        }

        return false;
    }

    @Override
    public boolean canPullUp() {

        if (isCanPullup) {


            if (getScrollY() >= getContentHeight() * getScale()
                    - getMeasuredHeight())
                return true;
            else
                return false;
        }

        return false;
    }

    public void setCanPullup(boolean isCanPullup) {
        this.isCanPullup = isCanPullup;
    }

    public void setCanPulldown(boolean isCanPuldown) {
        this.isCanPuldown = isCanPuldown;
    }
}
